<?php

declare(strict_types=1);

namespace App\Model;


/**
 * @property int $id ID
 * @property int $vendor_id 厂商ID
 * @property int $scene 场景值
 * @property int $userid 用户ID
 * @property string $username 用户名
 * @property string $mobile 手机号码
 * @property string $content 内容
 * @property string $validate_code 验证内容
 * @property int $validate_time 验证时间
 * @property int $add_time 发送时间
 */
class SmsLog extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'sms_log';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'vendor_id', 'scene', 'userid', 'username', 'mobile', 'content', 'validate_code', 'validate_time', 'add_time'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'vendor_id' => 'integer', 'scene' => 'integer', 'userid' => 'integer', 'validate_time' => 'integer', 'add_time' => 'integer'];

    /**
     * 置为已验证
     * @param $validId
     * @return int
     */
    public static function setValid($validId): int
    {
        return self::query()->where('id', $validId)->update(['validate_time' => time()]);
    }
}
